<template>
	<div> 
		<el-input 
			type="password" 
			v-if="data.type=='password'" 
			v-model="value"  
			@input="input" 
			@change="change"
			:disabled="data.disabled"
			 >
		</el-input> 
		 <el-input 
		 	:disabled="true"
		 	v-else-if="data.type=='selectData'" 
		 	v-model="data.showName" class="input-with-select"> 
			   <el-button slot="append" icon="el-icon-search" @click="selectData" ></el-button>
		  </el-input>
		 <el-input-number 
		 	:disabled="data.disabled"
		 	 :min="data.min" :max="data.max"
		 	v-else-if="data.type=='number'"   
		 	v-model="value" 
		 	 @input="input"    
		 	 @change="change"
		 	 
		 	
		 	 :precision="data.precision"
		 	></el-input-number>
	 	<el-select 
	 		:disabled="data.disabled"
	 		v-model="value" 
	 		@input="input"    
	 		@change="change"
	 		v-else-if="data.type=='select'"   
	 		placeholder="请选择">
		    <el-option
		      v-for="item in data.dic"
		      :key="item[data.dicCode?data.dicCode:'code']"
		      :label="item[data.dicName?data.dicName:'name']"
		      :value="item[data.dicCode?data.dicCode:'code']">
		    </el-option>
	  	</el-select>
		<el-date-picker   
			@change="change"
			@input="change"   
			:disabled="data.disabled"
			v-else-if="data.type=='date'"  
			v-model="value" 
			type="date" 
			placeholder="选择日期" >
		</el-date-picker> 
		<el-input
			v-else-if="data.type=='textarea'"  
			:disabled="data.disabled"
		  type="textarea"
		  :maxlength="data.max"
		  :show-word-limit="data.showWordLimit"
		  :rows="data.rows"
		  :placeholder="data.placeholder"
		  v-model="value" 
		  @input="input"   
		  @change="change"
		  >
		</el-input>
		<el-input type="text"  
			:disabled="data.disabled"
			v-else v-model="value" 
			@input="input"   
			@change="change"
			 ></el-input>
	</div>
</template>

<script>
	module.exports={
		props:[
			'data','value' 
		],
		data:function(){
			return { }
		}, 
		methods:{ 
			selectData:function(){
				var _this=this;
				if(this.data.disabled){
					
				}else{
					if(this.data&&this.data.call){
						this.data.call().then(function(item){ 
							_this.value=item.code;
							_this.data.showName=item.name;     
							_this.$emit("input",item.code);
							_this.$emit("change",item.code); 
						});
					}
				}
			},
			change:function(val){
				this.$emit("change",val); 
			},
			input:function(val){ 
				this.$emit("input",this.value);
			}
		}, 
		watch:{ 
		}
	}
</script>

<style>
</style>